package org.jypj.dev.util;

import org.jypj.dev.model.ShoesImg;

import java.util.List;
import java.util.UUID;

public class StringUtil {

    public static void main(String[] args) {
        System.out.println(getLowUUID());
    }

    public static boolean isEmpty(String str) {
        if ("".equals(str) || str == null) {

            return true;
        } else {
            return false;
        }

    }

    public static boolean isNotEmpty(String str) {
        if (!"".equals(str) && str != null) {

            return true;
        } else {
            return false;
        }
    }

    /**
     * 得到小写的UUID
     *
     * @return
     */
    public static String getLowUUID() {
        String s = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        return s;
    }

    /**
     * 将List转为字符串
     *
     * @param shoesImgList
     * @return
     */
    public static String getShoesImgStr(List<ShoesImg> shoesImgList) {
        StringBuffer stringBuffer = new StringBuffer();
        for (ShoesImg shoesImg : shoesImgList) {
            stringBuffer.append(shoesImg.getImageUrl() + ",");
        }
        if (isNotEmpty(stringBuffer.toString())) {
            String substring = stringBuffer.substring(0, stringBuffer.length() - 1);
            return substring;
        }
        return "";
    }
}
